package com.toman.Adpter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.toman.R;
import com.toman.bean.ItemBean;
import com.toman.bean.ItemListBean;

import java.util.List;

/**
 * Created by 邹苏隆 on 2018/5/10.
 * description：
 */

public class ItemListAdapter extends AdapterBase<ItemListBean, ItemHolder> {

    private LayoutInflater inflater;
    private Context mContext;
    private int mFlag = 1;

    public ItemListAdapter(Context context) {
        inflater = LayoutInflater.from(context);
        this.mContext = context;

    }
    public ItemListAdapter(Context context,int flag) {
        inflater = LayoutInflater.from(context);
        this.mContext = context;
this.mFlag=flag;
    }

    @Override
    protected void handlerData(List<ItemListBean> mList2, int position, ItemHolder itemView) {
        ItemListBean bean = mList2.get(position);
        itemView.tv_name.setText(bean.getName());
        if (mFlag==4){
            itemView.tv_content1.setText(bean.getRemark());
        }
        if (mFlag==5){
            itemView.tv_content1.setText("故障项目编号:"+bean.getRemark());
            itemView.tv_content2.setText("故障项目类别名称:"+bean.getRemark2());
            itemView.tv_content3.setText("修改时间:"+bean.getRemark3());
        }
        if (mFlag==6){
            itemView.tv_content1.setText("设备型号编号:"+bean.getRemark());
            itemView.tv_content2.setText("设备型号名称:"+bean.getRemark2());
            itemView.tv_content3.setText("设备类别名称:"+bean.getRemark3());
            itemView.tv_content4.setText("修改时间:"+bean.getRemark4());
        }
    }

    @Override
    protected ItemHolder getItemViewHolder() {
        return new ItemHolder();
    }

    @Override
    protected View initConvertView(View convertView, ItemHolder v) {
        convertView = inflater.inflate(R.layout.item_item_list, null);
        if (mFlag==2){
            convertView = inflater.inflate(R.layout.item_item_list_select, null);
        }
        if (mFlag==3){
            convertView = inflater.inflate(R.layout.item_item_list_small, null);
        }
        if (mFlag==4){
            convertView = inflater.inflate(R.layout.item_item_list_content, null);
            v.tv_content1=(TextView) convertView
                    .findViewById(R.id.tv_content1);

        }
        if (mFlag==5){
            convertView = inflater.inflate(R.layout.item_item_list_content_problem, null);
            v.tv_content1=(TextView) convertView
                    .findViewById(R.id.tv_content1);
            v.tv_content2=(TextView) convertView
                    .findViewById(R.id.tv_content2);
            v.tv_content3=(TextView) convertView
                    .findViewById(R.id.tv_content3);

        }
        if (mFlag==6){
            convertView = inflater.inflate(R.layout.item_item_list_content_mode, null);
            v.tv_content1=(TextView) convertView
                    .findViewById(R.id.tv_content1);
            v.tv_content2=(TextView) convertView
                    .findViewById(R.id.tv_content2);
            v.tv_content3=(TextView) convertView
                    .findViewById(R.id.tv_content3);
            v.tv_content4=(TextView) convertView
                    .findViewById(R.id.tv_content4);

        }
        v.tv_name = (TextView) convertView
                .findViewById(R.id.tv_name);
        return convertView;
    }

    @Override
    protected void onReachBottom() {

    }
}

